package com.example.plat.service.impl;

import com.example.plat.enity.Place;
import com.example.plat.exception.ActivityException;
import com.example.plat.mapper.PlaceMapper;
import com.example.plat.service.PlaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class PlaceServiceImpl implements PlaceService {

    @Autowired
    PlaceMapper mapper;

    @Override
    public Place getPlace(Long placeId) {
        return mapper.selectById(placeId);
    }

    @Transactional
    @Override
    public void createPlace(Place place) throws ActivityException {
        try {
            mapper.insert(place);
        }catch (Exception e){
            throw new ActivityException("地点错误！");
        }

    }

    @Override
    public void updatePlace(Place place) {
        mapper.updateById(place);
    }
}
